﻿<UserControl x:Class="DarklandsUiCommon.Views.Character.EquipmentListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">


    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../SharedStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Style TargetType="DataGridRow">
                <Setter Property="ValidationErrorTemplate">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid>
                                <Ellipse Width="12" Height="12" Fill="Red" />
                                <TextBlock FontWeight="Bold" Padding="4,0,0,0" Margin="0" VerticalAlignment="Top" Foreground="White" Text="!" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="true">
                        <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
                    </Trigger>

                </Style.Triggers>
            </Style>
        </ResourceDictionary>

    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto" 
                  Template="{DynamicResource SlimScrollViewerControlTemplate}" 
                  PreviewMouseWheel="OnPreviewMouseWheel">

        <DataGrid RowHeaderWidth="20" Name="EquipmentGrid" ItemsSource="{Binding Equipment.View}" AutoGenerateColumns="False" SelectionMode="Single">
            <DataGrid.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource GroupWithItemCount}" />
            </DataGrid.GroupStyle>

            <DataGrid.Columns>
                <!--<DataGridCheckBoxColumn Header="Equipped" Binding="{Binding IsEquipped, Mode=OneWay}" />-->
                <DataGridTextColumn Header="Name" Binding="{Binding Name, Mode=OneWay}" />
                <DataGridTextColumn Header="Quality" Binding="{Binding Item.Quality, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                <DataGridTextColumn Header="Quantity" Binding="{Binding Item.Quantity, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" Width="*" />
            </DataGrid.Columns>
        </DataGrid>

    </ScrollViewer>
</UserControl>
